package com.hailong.zyt.controller;


import com.hailong.zyt.beans.Student;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import com.hailong.zyt.service.CourseAllService;
import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpSession;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hailong
 * @since 2021-05-13
 */
@Slf4j
@Controller
public class CourseAllController {

    private CourseAllService courseAllService;

    @Autowired
    public void setCourseAllService(CourseAllService courseAllService) {
        this.courseAllService = courseAllService;
    }

    @GetMapping("/student/courses")
    public String toCourse(Model model, HttpSession session){
        Student student = (Student) session.getAttribute("student");
        model.addAttribute("courses", courseAllService.getStudentAllCourseById(student.getStuId()));
        return "/student/course/stuCourse";
    }
}

